fix sequence related undefined behavior found by PVS Studio.
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Tue, 23 Mar 2021 18:40:06 +0000 (12:40 -0600)
committertsteven4 <13596209+tsteven4@users.noreply.github.com>
Tue, 23 Mar 2021 18:40:06 +0000 (12:40 -0600)
V567 The modification of the 's' variable is unsequenced relative to another operation on the same variable. This may lead to undefined behavior.

brauniger_iq.cc
garmin_txt.cc
igc.cc

index 88188259e19a722ac4d2b863282e30ec637e22b7..071b6b754743ccf2290173952d5b19b1fa88bb0a 100644 (file)
@@ -54,7 +54,7 @@ inline state_t& operator++(state_t& s) // prefix
 inline state_t operator++(state_t& s, int) // postfix
 {
   state_t ret(s);
-  s = ++s;
+  ++s;
   return ret;
 }
 
index d3fa8c4b178723dd70f1b45ca72dde0187fc3ea1..bf4c91f42ee82aa65aba08bef677c1038a68bf83 100644 (file)
@@ -94,7 +94,7 @@ inline header_type& operator++(header_type& s) // prefix
 inline header_type operator++(header_type& s, int) // postfix
 {
   header_type ret(s);
-  s = ++s;
+  ++s;
   return ret;
 }
 
@@ -105,7 +105,7 @@ inline gt_display_modes_e& operator++(gt_display_modes_e& s) // prefix
 inline gt_display_modes_e operator++(gt_display_modes_e& s, int) // postfix
 {
   gt_display_modes_e ret(s);
-  s = ++s;
+  ++s;
   return ret;
 }
 
diff --git a/igc.cc b/igc.cc
index 950fdf5a3ef0d06c6035aec32a9f20f0af4249d2..1f5d772a538f70e309a679a7bdb98653ddca2fcf 100644 (file)
--- a/igc.cc
+++ b/igc.cc
@@ -156,7 +156,7 @@ inline state_t& operator++(state_t& s) // prefix
 inline state_t operator++(state_t& s, int) // postfix
 {
   state_t ret(s);
-  s = ++s;
+  ++s;
   return ret;
 }